<script type="text/javascript" src="${rc.getContextPath()}/manage/styles/treeGrid/javascripts/jquery.treetable-ajax-persist.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/manage/styles/treeGrid/javascripts/jquery.treetable-3.0.0.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/manage/styles/treeGrid/javascripts/persist-min.js"></script>
<link href="${rc.getContextPath()}/manage/styles/treeGrid/stylesheets/jquery.treetable.css" media="all" rel="stylesheet" type="text/css" />
<style>
.shortCheckbox
{
    width:100px;
}

.locationTable
{
 border-bottom: solid 1px #ededed;
}

.locationTable tr td{
    width:200px;
}

.locationTable tr td{
    text-align: left;
    overflow: hidden;
    padding: 0px 10px;
    vertical-align: middle;
    line-height: 22px;
    height: 22px;
    border-top: solid 1px #f7f7f7;
    border-right: solid 1px #ededed;
}
.locationTable tbody tr:first-child td{
      border-top: 0px;
}
.locationTable tr td:first-child
{ 
    
  border-top: solid 1px #f7f7f7;
  border-left: solid 1px #ededed;
  border-right: solid 1px #ededed;
}

.locationTable tr th:first-child
{
    border-color: #DFE4E8;
    border-style: solid;
    border-width: 1px;
}

.locationTable tr th{
    text-align: left;
    padding: 0px 10px;
    border-style: solid;
    border-width: 1px 1px 1px 0px;
    white-space: nowrap;
    line-height: 30px;
    border-color: #DFE4E8;
    background-color: #FAFCFC;
    color: #797E80;
    font-weight: bold;
    height: 26px;
}

</style>
<div class="pageContent">
    <form method="post"
        action="${rc.getContextPath()}/manage/warehouse/saveWarehouse"
        class="pageForm required-validate"
        onsubmit="return validateCallback(this, dialogAjaxDone);">
        <div class="pageFormContent" >
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (warehouse.warehouseCode)??>${warehouse.warehouseCode!''}</#if>">
            <fieldset>
                <dl>
                    <dt><@label key="WarehouseCode.C,colon">仓库编号：</@label></dt>
                    <dd>
                        <input name="warehouseCode" value="${warehouse.warehouseCode!''}" 
                              size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='WarehouseCode.C,alreadyExists'>仓库编号已存在</@label>"
                              <#if warehouse??>
                                  readonly="readonly"
                              <#else>
                                  remote="${rc.getContextPath()}/manage/warehouse/checkWarehouseCode"
                             </#if>
                        />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="WarehouseText.C,colon">仓库描述：</@label></dt>
                    <dd>
                        <input name="warehouseText"
                            value="${warehouse.warehouseText!''}"
                            size="22" type="text" maxlength="60" class="required" 
                              readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="WarehouseTypeCode.C,colon">仓库类型编号：</@label></dt>
                    <dd>
                        <input name="warehouseTypeCode" value="${warehouse.warehouseTypeCode!''}" 
                              size="22" type="text" maxlength="20" class="required"  readonly="readonly"
                        />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="WarehouseTypeText.C,colon">仓库类型描述：</@label></dt>
                    <dd>
                        <input name="warehouseTypeText" 
                            value="${warehouse.warehouseTypeText!''}"
                            size="22" type="text" maxlength="60" class="required" 
                              readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="place.C,colon">所在位置：</@label></dt>
                    <dd>
                        <input name="place" value="${warehouse.place!''}" 
                              size="22" type="text" maxlength="60"  readonly="readonly"
                        />
                    </dd>
                </dl>
                
                <dl >
                    <dd class="shortCheckbox">
                        <label><input type="checkbox" name="locationManageFlag" value="1"
                            <#if "view"==pattern>
                            disabled="disabled"
                            </#if>
                            <#if
                            (warehouse.locationManageFlag)?? && (warehouse.locationManageFlag == 1)>
                            checked="true"</#if>><@label key="locationManageFlag.C">启用库位</@label></label>
                    </dd>
                    <dd class="shortCheckbox">
                        <label><input type="checkbox" name="negativeInventoryFlag" value="1"
                            <#if "view"==pattern>
                            disabled="disabled"
                            </#if>
                            <#if
                            (warehouse.negativeInventoryFlag)?? && (warehouse.negativeInventoryFlag == 1)>
                            checked="true"</#if>><@label key="negativeInventoryFlag.C">允许负库存</@label></label>
                    </dd>
                    <dd class="shortCheckbox">
                        <label><input type="checkbox" name="lockFlag" value="1"
                            <#if "view"==pattern>
                            disabled="disabled"
                            </#if>
                            <#if
                            (warehouse.lockFlag)?? && (warehouse.lockFlag == 1)>
                            checked="true"</#if>><@label key="lock.C">锁定</@label></label>
                    </dd>
                </dl>
                
            </fieldset>
        </div>
                <div class="panel" style="width:96%;margin:5px auto ;border-top:1px solid #d8dfe5;">
                <h1><@label key="assignedStorageLocation.C,colon">已分配的库位</@label></h1>
                    <div >
                        <div id="theadDiv">
                            <table id="locationThead" class="locationTable" style="overflow:scroll"width="100%">
                                <thead>
                                    <tr id="theadTr">
                                        <th><@label key="code.C">编号</@label></th>
                                        <th><@label key="description.C">描述</@label></th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                         <table id="locationTable" class="locationTable" width="100%" layoutH="340">
                            <tbody>
                             <#if storageLocationTypeList?? && (storageLocationTypeList?size) gt 0> 
                                <#list storageLocationTypeList as locationType>
                                     <tr data-tt-id="${locationType.storageLocationTypeCode}"  >
                                         <td>${locationType.storageLocationTypeCode}</td>
                                         <td>${locationType.storageLocationTypeText}</td>
                                     </tr>
                                     <#list locationType.storageLocationList as location>
                                         <tr data-tt-id="${location.storageLocationCode}" data-tt-parent-id="${locationType.storageLocationTypeCode}" >
                                             <td>${location.storageLocationCode}</td>
                                             <td>${location.storageLocationText}</td>
                                         </tr>
                                     </#list> 
                                  </#list> 
                              </#if>
                            </tbody>
                        </table>
                    </div>
            </div> 
        <#if warehouse??>
            <#assign createInfo=warehouse>
            <#include "/common/createInfo.html">
        </#if>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                                <button type="button" class="close"><@label key="close.B">关闭</@label></button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script>
    var dialog=$.pdialog.getCurrent();
    $("#locationTable",dialog).find("thead tr").empty();
    var $table=$("#locationTable",dialog);
    var $theadTh=$("#theadTr th",dialog);
     $table.find("tr:first > td").each(function(i,o){
             $theadTh[i].width=$(this).width();
         });

     $table.agikiTreeTable({persist: false});  //true为保存上次树的展开状态
     
     $table.on("click","tr",function(){
          var d=$("#locationThead thead",dialog).width()-$table.find("tbody").width();
          if(d>0){
              $("#theadDiv",dialog).width($table.find("tbody").width());
          }
          else
         {
              $("#theadDiv",dialog).css("width","100%");
         }
         $(this).find("td").each(function(i,o){
             $theadTh[i].width=$(this).width();
         });
     })
</script>    